package com.glacier.excel.domain.builder;

import com.glacier.excel.domain.ExcelPropertyMeta;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * date 2021-06-17 17:13
 *
 * @author glacier
 * @version 1.0
 */
public final class ExcelPropertyMetaBuilder {
    private Field field;
    private Method methodGetter;
    private Method methodSetter;
    private String[] value;
    private String[] validate;
    private int index;
    private int order;
    private int width;
    private Class<?> converter;
    
    private ExcelPropertyMetaBuilder() {
    }
    
    public static ExcelPropertyMetaBuilder anExcelPropertyMeta() {
        return new ExcelPropertyMetaBuilder();
    }
    
    public ExcelPropertyMetaBuilder withField(Field field) {
        this.field = field;
        return this;
    }
    
    public ExcelPropertyMetaBuilder withMethodGetter(Method methodGetter) {
        this.methodGetter = methodGetter;
        return this;
    }
    
    public ExcelPropertyMetaBuilder withMethodSetter(Method methodSetter) {
        this.methodSetter = methodSetter;
        return this;
    }
    
    public ExcelPropertyMetaBuilder withValue(String[] value) {
        this.value = value;
        return this;
    }
    
    public ExcelPropertyMetaBuilder withValidate(String[] validate) {
        this.validate = validate;
        return this;
    }
    
    public ExcelPropertyMetaBuilder withIndex(int index) {
        this.index = index;
        return this;
    }
    
    public ExcelPropertyMetaBuilder withOrder(int order) {
        this.order = order;
        return this;
    }
    
    public ExcelPropertyMetaBuilder withWidth(int width) {
        this.width = width;
        return this;
    }
    
    public ExcelPropertyMetaBuilder withConverter(Class<?> converter) {
        this.converter = converter;
        return this;
    }
    
    public ExcelPropertyMeta build() {
        ExcelPropertyMeta excelPropertyMeta = new ExcelPropertyMeta();
        excelPropertyMeta.setField(field);
        excelPropertyMeta.setMethodGetter(methodGetter);
        excelPropertyMeta.setMethodSetter(methodSetter);
        excelPropertyMeta.setValue(value);
        excelPropertyMeta.setValidate(validate);
        excelPropertyMeta.setIndex(index);
        excelPropertyMeta.setOrder(order);
        excelPropertyMeta.setWidth(width);
        excelPropertyMeta.setConverter(converter);
        return excelPropertyMeta;
    }
}
